package objects;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name = "Threads")
public class Trd
{
	@Id
	private ThreadPK threadPk = new ThreadPK();
//	@OneToMany(targetEntity=Message.class, mappedBy="messagePK.thread", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
//	private List<Message> messages;

	public Frm getForum()
	{
		return threadPk.getForum();
	}

	public void setForum(Frm forumName)
	{
		threadPk.setForum(forumName);
	}

	public String getThreadName()
	{
		return threadPk.getThreadName();
	}

	public void setThreadName(String threadName)
	{
		threadPk.setThreadName(threadName);
	}

//	public List<Message> getMessages()
//	{
//		return messages;
//	}
//
//	public void setMessages(List<Message> messages)
//	{
//		this.messages = messages;
//	}


	@Embeddable
	private static class ThreadPK implements Serializable
	{
		@ManyToOne
		private Frm forum;
		private String threadName;

		public Frm getForum()
		{
			return forum;
		}

		public void setForum(Frm forum)
		{
			this.forum = forum;
		}

		public String getThreadName()
		{
			return threadName;
		}

		public void setThreadName(String threadName)
		{
			this.threadName = threadName;
		}

	}
}

